import java.util.*;



public class BM {

    public static void main(String args[]) {

        int n;

        int a[] = new int[100];

        int i, j, q, l = 0, m = -1, d;

        int t[] = new int[100];

        int f[] = new int[100];

        int b[] = new int[100];

        t[0] = 1;

        f[0] = 1;

        b[0] = 1;

        System.out.printf("0、1序列的长度n为：\n");

        Scanner h = new Scanner(System.in);

        n = h.nextInt();

        System.out.printf("输入的0、1序列为（每输入一个数字敲一下回车）：\n");

        for (i = 0; i < n; i++) {

            Scanner g = new Scanner(System.in);

            a[i] = g.nextInt();

            a[i] = a[i]%2;

        }

        for (i = 0; i < n; i++) {

            if (i == 0)

                d = a[i];

            else {

                d = a[i];

                j = 1;

                while (j <= i) {

                    d = d ^ (f[j] * a[i - j]);

                    j++;

                }

                d = d;

            }

            if (d == 1) {

                for (q = 0; q <= n; q++)

                    t[q] = f[q];

                for (j = 0; j <= n; j++)

                    if (b[j] == 1)

                        f[j + i - m] = (f[j + i - m] + 1) % 2;

                if (l <= i / 2) {

                    l = i + 1 - l;

                    m = i;

                    for (q = 0; q <= n; q++)

                        b[q] = t[q];

                }



            }

        }

        System.out.printf("L=%d\n", l);

        System.out.printf("%d", f[0]);

        for (i = 1; i <= n; i++)

            if (f[i] != 0)

                System.out.printf("+x^%d", i);

        System.out.printf("\n");

    }

}
